/**
* WordCountTopologyUB is used to run a demo topology with "split" sentence bolt as an updatable bolt.
* It can be updated to a different version which is not specified at the topology building time by making use of signals.
*
*
* @author Tarun Sharma
* @version 1.0
* @see <a href="http://www.dream-lab.in/">DREAM:Lab</a>
*
* Copyright 2014 DREAM:Lab, Indian Institute of Science, 2014
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package mypackage.topology;
import mypackage.bolts.SplitSentence;
import mypackage.bolts.WordCount;
import mypackage.spouts.RandomSentenceSpout;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
import backtype.storm.utils.Utils;
public class WordCountTopology {
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("sentences", new RandomSentenceSpout(), 1);
// UpdatableBoltLocationEntry updatableEntry = new UpdatableBoltLocationEntry("1", "v1", "in.dream_lab.stream.storm.samples.wordcount.bolts.SplitSentence");
// IUpdatableBolt b1 = UpdateFactory.newUpdatableBolt(updatableEntry, "topoName", "split");
// builder.setBolt("split", b1, 1).shuffleGrouping("sentences");
builder.setBolt("split", new SplitSentence(), 1).shuffleGrouping("sentences");
builder.setBolt("count", new WordCount(), 1).fieldsGrouping("split", new Fields("word"));
//System.out.println("SIGNAME IS " + b1.getSignalName());
Config conf = new Config();
conf.setDebug(true);
if (args != null && args.length > 0) {
conf.setNumWorkers(3);
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.killTopology("test");
cluster.shutdown();
}
}
}